<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "article".
 *
 * @property integer $id
 * @property string $title
 * @property string $content
 * @property integer $inputtime
 */
class Article extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'article';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['content'], 'string'],
            [['inputtime'], 'integer'],
            [['title'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '标题',
            'content' => '内容',
            'inputtime' => '发布时间',
        ];
    }

    public function getBeginning()
    {
        $tmpStr = strip_tags($this->title);
        $tmpLen = mb_strlen($tmpStr);
        return mb_substr($tmpStr,0,30,'utf-8').(($tmpLen>30)?'...':'');
    }
}
